function DragUpdate takes nothing returns nothing
	local timer extendWebTimer = GetExpiredTimer()
	local integer extendWebTimerId = GetHandleId(extendWebTimer)
	local unit caster = LoadUnitHandle(udg_HT , extendWebTimerId , StringHash("CASTER"))
	local location frontLocation = LoadLocationHandle(udg_HT , extendWebTimerId , StringHash("FRONT_LOCATION"))
	local real dx = LoadReal(udg_HT , extendWebTimerId , StringHash("DX"))
	local real dy = LoadReal(udg_HT , extendWebTimerId , StringHash("DY"))
	local unit colUnit = LoadUnitHandle(udg_HT , extendWebTimerId , StringHash("COL_UNIT"))
	local lightning webLightning = LoadLightningHandle(udg_HT , extendWebTimerId , StringHash("WEB"))
	local location realColLocation = null
	local group colUnits = null
	//--
	call MoveLocation(frontLocation , GetLocationX(frontLocation) + dx , GetLocationY(frontLocation) + dy)
	call SetUnitPositionLoc(colUnit , frontLocation)
	set realColLocation = GetUnitLoc(colUnit)
	
	if DistanceBetweenPoints(frontLocation , realColLocation) > 5.0 then
		set colUnits = GetUnitsInRangeOfLocMatching(70.0 , frontLocation , null)
		if FirstOfGroup(colUnits) == null then
			call BJDebugMsg("col tree")
		else
			call BJDebugMsg("col unit")
		endif	
		
		call PauseTimer(extendWebTimer)
		call FlushChildHashtable(udg_HT , extendWebTimerId)
		call DestroyTimer(extendWebTimer)
		call DestroyLightning(webLightning)
		call KillUnit(colUnit)
		call RemoveUnit(colUnit)
	else
		call MoveLightning(webLightning , true , GetUnitX(caster) , GetUnitY(caster) , GetLocationX(frontLocation) , GetLocationY(frontLocation))
	endif
	//--
endfunction

function DragAction takes nothing returns nothing
	local unit caster = GetTriggerUnit()
	local location casterLocation = GetUnitLoc(caster)
	local location targetLocation = GetSpellTargetLoc()
	local real angle = AngleBetweenPoints(casterLocation , targetLocation) 
	local real dx = Cos(angle * bj_DEGTORAD) * 15.0
	local real dy = Sin(angle * bj_DEGTORAD) * 15.0
	local location frontLocation = Location(GetLocationX(casterLocation) + dx * 5.0 , GetLocationY(casterLocation) + dy * 5.0)
	local unit colUnit = CreateUnit(GetOwningPlayer(caster) , 'h001' , GetLocationX(frontLocation) , GetLocationY(frontLocation) , 0.0)
	local lightning webLightning = AddLightning("LEAS" , true , GetUnitX(caster) , GetUnitY(caster) , GetUnitX(caster) , GetUnitY(caster))
	local timer extendWebTimer = CreateTimer()
	local integer extendWebTimerId = GetHandleId(extendWebTimer)
	//--
	call PauseUnit(colUnit , true)
	call ShowUnit(colUnit , false)
	
	call SaveUnitHandle(udg_HT , extendWebTimerId , StringHash("CASTER") , caster)
	call SaveLocationHandle(udg_HT , extendWebTimerId , StringHash("FRONT_LOCATION") , frontLocation)
	call SaveReal(udg_HT , extendWebTimerId , StringHash("DX") , dx)
	call SaveReal(udg_HT , extendWebTimerId , StringHash("DY") , dy)
	call SaveUnitHandle(udg_HT , extendWebTimerId , StringHash("COL_UNIT") , colUnit)
	call SaveLightningHandle(udg_HT , extendWebTimerId , StringHash("WEB") , webLightning)
	
	call TimerStart(extendWebTimer , 0.01 , true , function DragUpdate)
	//--
endfunction

function DragTry takes nothing returns nothing
	if GetSpellAbilityId() == 'A000' then
		call DragAction()
	endif
endfunction

function InitTrig_Drag takes nothing returns nothing
	set gg_trg_Drag = CreateTrigger()
	call TriggerRegisterAnyUnitEventBJ(gg_trg_Drag , EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddAction(gg_trg_Drag , function DragTry)
endfunction